package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: atp
 * Date: 2022-10-28
 * Time: 16:03
 */
class Shape {
    public void draw() {
        System.out.println("画图型");
    }
}
class Rect extends Shape {
    @Override
    public void draw() {
        System.out.println("画矩形");
    }
}
class Cycle extends Shape {
    @Override
    public void draw() {
        System.out.println("画圆形");
    }
}
class Triangle extends Shape {
    @Override
    public void draw() {
        System.out.println("画三角");
    }
}

public class Test {
    public static void drawmap(Shape shape) {
        shape.draw();
    }
    public static void drawShapes() {
        Shape[] shapes = {new Rect(),new Cycle(),new Triangle()};
        for (Shape s : shapes) {
            s.draw();
        }
    }

    public static void main2(String[] args) {

        drawmap(new Rect());
        drawmap(new Cycle());
        drawmap(new Triangle());
    }

    public static void main1(String[] args) {
        Shape shape = new Rect();
        shape.draw();

        Shape shape1 = new Cycle();
        shape1.draw();

        Shape shape2 = new Triangle();
        shape2.draw();
    }
}
